﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PPAP.BO;
using System.Data;

namespace PPAP.Web.Logistic
{
    public partial class Todolist : PageBase
    {
        SignBO sbo = new SignBO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DataSet ds = sbo.GetSignList();
                AspNetPager2.RecordCount = ds.Tables[0].Rows.Count;
                dgList.DataSource = GetPageTable(ds.Tables[0], AspNetPager2.PageSize, AspNetPager2.CurrentPageIndex);
                dgList.DataBind();

            }
        }

        protected override void SkinControl()
        {

        }

        public static DataTable GetPageTable(DataTable dt, int pageSize, int pageIndex)
        {
            if (dt != null)
            {
                DataTable dt1 = new DataTable();

                int pageEnd = pageIndex * pageSize;
                int pagebegin = (pageIndex - 1) * pageSize;


                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    dt1.Columns.Add(new DataColumn(dt.Columns[i].ColumnName));
                }

                for (int i = pagebegin; i < pageEnd; i++)
                {
                    if (i < dt.Rows.Count)
                    {
                        dt1.ImportRow(dt.Rows[i]);
                    }

                }
                return dt1;
            }
            else
                return null;
        }



        protected void btnSearch_Click(object sender, EventArgs e)
        {

        }

        protected void AspNetPager2_PageChanged(object sender, EventArgs e)
        {
            DataSet ds = sbo.GetSignList();
            AspNetPager2.RecordCount = ds.Tables[0].Rows.Count;
            dgList.DataSource = GetPageTable(ds.Tables[0], AspNetPager2.PageSize, AspNetPager2.CurrentPageIndex);
            dgList.DataBind();
        }
    }
}